<template>
	<view class="lookInfo">
		<!-- 设备归还 --- 查看记录 --- 详情 页面 -->
		<navBar title="查看详情" goBackUrl="/subpackage-equipment/pages/device/deviceGoBack/deviceGoBack" @goBack="goBack"></navBar>
		
		<scroll-view scroll-y="true" class="scroll-box">
			<view class="content">
				<view class="project">
					<image class="image" src="/subpackage-equipment/static/project1.png" mode=""></image>
					<view class="name">
						<view class="t1">{{ projectName || "" }}</view>
						<view class="t2">{{ subProjectName || "" }}</view>
					</view>
				</view>
				
				<view class="box uniCollapse">
					<view class="nav border">
						<view class="name">归还编号</view>
						<view class="value">{{ deviceInfoObj.code || "" }}</view>
					</view>
					<view class="nav border">
						<view class="name">关联出库编号</view>
						<view class="value">{{ deviceInfoObj.exCode || "" }}</view>
					</view>
					
					<view class="nav border">
						<view class="name">设备归还单</view>
						<view class="value width">{{ total }}</view>
					</view>
			
					<uni-collapse>
					    <uni-collapse-item v-for="(item, index) in deviceInfoList" title-border="show" :key="index" :title="item.subDeviceTypeName" :value="item.totalNum+''">
							<template v-slot:title>
								<view class="collapse-title">
									<view class="left">
										{{ item.subDeviceTypeName }}
									</view>
									<view class="right">
										{{ item.totalNum }}
									</view>
								</view>
							</template>
							<view class="center" v-for="value in item.infoList">
								<view class="item">
									<view class="name">设备编号：</view>
									<view class="value">{{ value.eqCode }}</view>
								</view>
								<view class="item">
									<view class="name">规格型号：</view>
									<view class="value">{{ value.specificationModel }}</view>
								</view>
								<!-- <view class="item">
									<view class="name">存储区域：</view>
									<view class="value">{{ value.storageAreaName }}</view>
								</view> -->
								<view class="item">
									<view class="name">基地名称：</view>
									<view class="value">{{ value.stationName }}</view>
								</view>
							</view>
					    </uni-collapse-item>
					</uni-collapse>
				</view>
				
				<!-- <view class="flow">
					<view class="f-title">流程</view>
					<view class="f-body">
						<u-steps class="step" current="1" dot direction="column" activeColor="#2F80ED" inactiveColor="#2F80ED">
							<u-steps-item title="出库提交" desc="2月15日  18:25"></u-steps-item>
							<u-steps-item title="出库审核通过" desc="2月15日  18:25"></u-steps-item>
							<u-steps-item title="归还提交" desc="2月15日  18:25"></u-steps-item>
							<u-steps-item title="归还审核通过" desc="2月15日  18:25"></u-steps-item>
						</u-steps>
						<view class="user">
							<view class="user-item" v-for="item in 4">
								<image class="userImg" src="/static/image/dispatch/user.png" mode=""></image>
								<text class="username">卢灵风</text>
							</view>
						</view>
					</view>
				</view> -->
			</view>
		</scroll-view>
		
	</view>
</template>

<script>
	import navBar from "@/components/navBar/navBar.vue"
	import { getDetailByReturnWarehouseCode } from "@/api/device/deviceOut.js"
	import mixins from "@/utils/mixins.js"
	import uniCollapse from "./../../../components/uni-collapse/components/uni-collapse/uni-collapse.vue";
	export default {
		name: "lookInfo",
		mixins: [mixins],
		components: {
			navBar,uniCollapse
		},
		data() {
			return {
				code: "",      // 归还编号
				projectName: "",   // 项目名称
				subProjectName: "",   // 标段和工点名称
				deviceInfoObj: {},
				deviceInfoList: [],   // 设备归还详情
				total: 0,             // 总数量
			}
		},
		onLoad(option) {
			this.code = option.code || ""
			this.projectName = option.projectName || ""
			this.subProjectName = option.subProjectName || ""
			this.getDeviceInfoList(this.code)
		},
		methods: {
			getDeviceInfoList(code){
				getDetailByReturnWarehouseCode({code}).then(res=>{
					if(res.result && res.result.length > 0){
						this.deviceInfoObj = {}
						
						this.deviceInfoObj = {
							code: res.result[0].code,
							exCode: res.result[0].exCode,
						}
						
						this.total = res.result.length || 0
						let list = res.result.map(item=>({...item, totalNum: 1}))
						this.deviceInfoList = this.DelSameObjValue(list, 'subDeviceTypeName', 'totalNum').map(item=>({subDeviceTypeName: item.subDeviceTypeName, totalNum: item.totalNum,infoList: []}))
						this.deviceInfoList.forEach(item=>{
							list.forEach(value=>{
								if(item.subDeviceTypeName === value.subDeviceTypeName){
									item.infoList.push(value)
								}
							})
						})
						console.log(this.deviceInfoList)
					}
					
				})
			},
			
			goBack(url){
				uni.navigateBack({
					url:url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.lookInfo{
		font-family: PingFang SC-Bold, PingFang SC;
		/* #ifdef MP-WEIXIN */
			padding-top: 180rpx;
		/* #endif */
		.scroll-box{
			height: calc(100vh - 170rpx);
			padding-top: 10rpx;
		}
		.content{
			background: #F5F7FA;
			padding-top: 30rpx;
			.project{
				background-color: #FFFFFF;
				padding: 0rpx 30rpx;
				height: 150rpx;
				display: flex;
				align-items: center;
				padding-top: 40rpx;
				box-sizing: border-box;
				.image{
					width: 70rpx;
					height: 70rpx;
					margin-left: 29rpx;
					margin-right: 40rpx;
				}
				.name{
					.t1{
						font-size: 32rpx;
						font-weight: bold;
						color: #445469;
					}
					.t2{
						font-size: 28rpx;
						font-weight: 500;
						color: #6A819E;
						margin-top: 5rpx;
					}
				}
			}
			
			.box{
				padding: 0rpx 30rpx;
				background-color: #FFFFFF;
			}
			.nav{
				line-height: 100rpx;
				height: 100rpx;
				padding: 0rpx 28rpx;
				display: flex;
				justify-content: space-between;
				
				.name{
					font-size: 32rpx;
					font-weight: bold;
					color: #445469;
				}
				.value{
					font-size: 32rpx;
					font-weight: bold;
					color: #445469;
				}
				.width{
					width: 120rpx;
					text-align: center;
				}
			}
			.border{
				border-bottom: 1rpx solid #d6d7d9;
			}
			
			.center{
				background-color: #FBFDFF;
				padding: 32rpx 38rpx;
				padding-top: 12rpx;
				border-bottom: 2rpx solid #E2E5ED;
				.item{
					display: flex;
					margin-top: 20rpx;
					
					.name{
						width: 150rpx;
					}
				}
			}
		}
		
		.flow{
			margin-top: 30rpx;
			background-color: #FFFFFF;
			padding-left: 62rpx;
			padding-right: 72rpx;
			padding-top: 36rpx;
			.f-title{
				font-size: 30rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #22204E;
				margin-bottom: 54rpx;
			}
			.f-body{
				height: 200rpx;
				padding-left: 10rpx;
				display: flex;
				.user{
					flex: 1;
					.user-item{
						text-align: right;
						margin-bottom: 150rpx;
					}
					.userImg{
						width: 50rpx;
						height: 50rpx;
						vertical-align: middle;
						margin-right: 14rpx;
					}
					.username{
						font-size: 22rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 500;
						color: #6A819E;
					}
						
				}
			}
		}
	}
</style>
